<!DOCTYPE html>
<html lang="en">
<head>
    <title>意向客户列表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="refresh" content="1200">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=86e2297f">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=222aea35">
    <style>
        .lineOne{
            text-align: left;
        }
        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }
        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }

    </style>
</head>
<body>
<section class="content"  id="app" >
    <div class="div-td-content-more"><i></i></div>
    <div class="box-body no-padding iframeH2" style="overflow: auto;" id="scrollDiv">
        <table class="table table-bordered text-center table-width">
            <thead>
            <tr>
                <!--<th style="width: 5%">序号</th>-->
                <th style="width: 10%">部门/大区</th>
                <th style="width: 10%">岗位</th>
                <th style="width: 8%">姓名</th>
                <th style="width: 8%">一周内</th>
                <th style="width: 8%">一月内</th>
                <th style="width: 8%">一月以上</th>
                <th style="width: 8%">总数量</th>
                <th style="width: 35%">区域</th>
            </tr>
            </thead>
            <tbody>
            <template v-if="intentionalCustomer.list.length>0">
                <tr v-for="(item,i) in intentionalCustomer.list">
                    <!--<td>{{i+1}}</td>-->
                    <td :rowspan="item.departNamespan" :class="{hidden: item.departNamedis}">
                        {{item.departName}}
                    </td>
                    <td>{{item.roleName}}</td>
                    <td @click="gotoDetail(item)" style="color:#169BD5;cursor: pointer;" class="openUserBox" :attrid="item.userId">{{item.userName}}</td>
                    <td v-if="item.weekNum&&item.weekNum!='-'" @click="openIntentionalCustomerList(item.userId,true,'一周内')"
                        style="color:#169BD5;cursor: pointer;">{{item.weekNum}}</td>
                    <td v-else>{{item.weekNum}}</td>
                    <td v-if="item.MonNum&&item.MonNum!='-'" @click="openIntentionalCustomerList(item.userId,true,'一月内')"
                        style="color:#169BD5;cursor: pointer;">{{item.MonNum}}</td>
                    <td v-else>{{item.MonNum}}</td>
                    <td v-if="item.MoreNum&&item.MoreNum!='-'" @click="openIntentionalCustomerList(item.userId,true,'一月以上')"
                        style="color:#169BD5;cursor: pointer;">{{item.MoreNum}}</td>
                    <td v-else>{{item.MoreNum}}</td>
                    <td v-if="item.num&&item.num!='-'" @click="openIntentionalCustomerList(item.userId,true,'')"
                        style="color:#169BD5;cursor: pointer;">{{item.num}}</td>
                    <td v-else>{{item.num}}</td>
                    <td class="lineOne">
                        <span>{{item.regionName}}</span>
                    </td>
                </tr>
                <tr>
                    <td>合计</td>
                    <td></td>
                    <td></td>
                    <td>{{intentionalCustomer.weekNumCount}}</td>
                    <td>{{intentionalCustomer.monNumCount}}</td>
                    <td>{{intentionalCustomer.moreNumCount}}</td>
                    <td>{{intentionalCustomer.allNumCount}}</td>
                    <td></td>
                </tr>
            </template>
            <template v-else>
                <tr><td colspan="8">为什么？</td></tr>
            </template>
            </tbody>
        </table>
    </div>

    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=8e743a31"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=54c6b89c"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
    var app = new Vue({
        el:'#app',
        data:{
            companyId: $.wyui.page.urlParams.companyId?$.wyui.page.urlParams.companyId:getCurrentUser().companyId,
            key:"",
            intentionalCustomer:{
                time: new Date().Format("yyyy-MM-dd"),
                list: [],
                weekNumCount:'',
                monNumCount:'',
                moreNumCount:'',
                allNumCount:''
            },userBox:{
                name:'',
                tel:'',
                roleName:'',
                entryDate:'',
                dayNumber:''
            }
        },
        methods:{
            gotoDetail: function (item) {
                top.$.dialog({
                    content: 'url:/page/personnel/entry.html?id=' + item.userId+ '&pageType=look',
                    title: item.userName + "详情",
                    width: 904,
                    height: 613,
                    max: true,
                    min: true,
                    lock: true
                }).max();
            },
            //合并单元格
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '') {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            },
            getList:function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.intentCustomerNew.getForDepartByCompanyId, {
                    "companyId": that.companyId,
                    "key":that.key
                }, function (data) {
                    console.log(data);
                    var data=trimRN2(data);
                    that.intentionalCustomer.list = that.tablesMergeCell(data);
                    that.intentionalCustomer.weekNumCount = that.getCount( that.intentionalCustomer.list, "weekNum");
                    that.intentionalCustomer.monNumCount = that.getCount( that.intentionalCustomer.list, "MonNum");
                    that.intentionalCustomer.moreNumCount = that.getCount( that.intentionalCustomer.list, "MoreNum");
                    that.intentionalCustomer.allNumCount = that.getCount( that.intentionalCustomer.list, "num");
                });
            },
            //打开意向客户列表
            openIntentionalCustomerList:function (userId,type,key) {
                var that=this;
                if(!userId){
                    userId=this.userId
                }
                if (!key) {
                    key="";
                }
                top.closeTabByPageId("openIntentionalCustomerList");
                top.addTabs({id:'openIntentionalCustomerList',title: '意向客户列表',close: true,url:'intentCustomerReportNew/intentionalCustomerList.html?userId='+ userId + '&isAll=' + false+'&key=' + key});
            },
            //获取合计
            getCount: function (arr, key) {
                var number = 0;
                for (var i = arr.length - 1; i >= 0; i--) {
                    number += (arr[i][key] && arr[i][key] != '-' ? arr[i][key] : 0)

                }
                return number;
            }
        },
        mounted:function () {
            this.getList();
        }
    });

</script>
</body>
</html>